<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>学校部门管理</title>
    <style>
        #app  {
        }
        table{
            width:1000px;
            margin:0 auto;
            font-size: 30px;
            border-collapse: collapse;
        }
        table,td{
            border:solid 1px red;

        }
    </style>
    <script src="./js/vue.js"></script>
    <script src="./js/axios.min.js"></script>
<!--    <script src="https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/2.6.14/vue.min.js"></script>-->
<!--    <script src="https://cdn.staticfile.org/axios/0.18.0/axios.min.js"></script>-->
</head>
<body>
<h1>学校部门管理</h1>
<div id="app">
    <table>
        <tr>
            <th>ID</th>
            <th>部门名称</th>
            <th>创建日期</th>
            <th>更新日期</th>
            <th>操作1</th>
        </tr>
        <tr v-for="dept in depts">
            <td>{{dept.id}}</td>
            <td>{{dept.name}}</td>
            <td>{{dept.createTime}}</td>
            <td>{{dept.updateTime}}</td>
            <td>删除</td>
            <td>更新</td>
        </tr>
    </table>
</div>
<script>
    new Vue({
        el: "#app",  //作用的范围
        data: { //要渲染按的数据
            depts: []
        },
        mounted() {  //生命周期 决定数据渲染的阶段 ：前端页面完全加载完成后渲染后端数据
            this.fetchAllData();
        },
        methods: {  //执行的业务逻辑  比如发起数据请求
            fetchAllData() {
                axios.get('http://localhost:8080/dept').then(
                    response => {
                        this.depts = response.data.data;
                    }
                )
            }
        }

    })
</script>
</body>
</html>